﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using oLGame.Game.Items.Weapons;
using oLGame.Game;
using oLGame.Game.World;
using oLGame.Game.Items.Containers;
namespace oLGame.Game.Players
{
    class Player : Entity
    {
        private double maxHealth, maxMana, maxStamina;
        protected double currentHealth, currentMana, currentStamina;
        protected Weapon currentWeapon = null;
        protected Backpack playerBackpack = new Backpack();
          
        public Player(double health, double mana, double stamina)
        {
            Name = "Player";
            maxHealth = currentHealth = health;
            maxMana = currentMana = mana;
            maxStamina = currentStamina = stamina;
        }

        public void Equip(Weapon weapon)
        {
            // Engine.AddAction(new PlayerEquipWeapon(this, weapon));
            if (weapon != null)
                this.Weapon = weapon;
        }

        public void Attack(Player target)
        {
            Engine.AddAction(new PlayerAttackAction(this, target));
        }

        public void TakeDamage(int amount)
        {
            // Engine.AddAction(new PlayerRecieveDamage(this, amount));
            currentHealth -= amount;
        }

        public bool IsDead()
        {
            if (this.currentHealth <= 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public Weapon Weapon
        {
            get { return currentWeapon; }
            // Not sure if allowing to set this is smart, but it will work for now. 
            // There needs to be an id for each item or something, perhaps a hash table.
            set { currentWeapon = value; }
        }

        public Backpack Backpack
        {
            get { return playerBackpack; }
            set { playerBackpack = value; }
        }
    }
}
